/*
 *      net-sim - net_interfaces
 *
 * 		Interfaces.java
 *
 *      Copyright 23/12/2008 nicolas
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 3 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */
package net_interfaces;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import networkProtocols.IP.Address.IpAddress;
import networkProtocols.IP.Address.Mask;
import exceptions.NodeException;

// TODO: do it "bosta" ... is a collection of things!!!
/**
 * The Class Interfaces.
 */
public class Interfaces {

  /** The ifaces. */
  public Map<String, Interface> ifaces = null;  // Tabla con las interfaces

  /**
   * Instantiates a new interfaces.
   */
  public Interfaces(){
    ifaces=new HashMap<String, Interface>();
  }

  // Agrega una interfaz a la lista. Se deberia chequear validez
  /**
   * Adds the interface.
   *
   * @param name the name
   * @param addr the addr
   * @param msk the msk
   * @param mtu the mtu
   *
   * @return the interface
   *
   * @throws NodeException the node exception
   */
  public Interface addInterface(String name, IpAddress addr, Mask msk, Integer mtu ) throws NodeException  {
    Interface ifc1 = new Interface(name, addr, msk, mtu);
    ifaces.put(name, ifc1);
    return ifc1;
  }

  /* (non-Javadoc)
   * @see java.lang.Object#toString()
   */
  public String toString() {
    Set<String> keySet = ifaces.keySet();
    for (String elementKey : keySet) {
      Interface i = ifaces.get(elementKey);
      System.out.println("Iface: "+ i.toString());
    }
    return "eee";
  }

}



